// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
// router
import router from './router'
// element ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

// import myrequest
import myRequest from './common/request.js'
Vue.prototype.$request = myRequest
// import myconfig
import config from './common/config.js'
Vue.prototype.$config = config
// import common js
import myfuncs from './common/common.js'
Vue.prototype.$funcs = myfuncs

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

//【前端】js vue 屏蔽BackSpace键删除键导致页面后退的方法
document.addEventListener('DOMContentLoaded', function () {
  document.body.addEventListener('keydown', function (e) {
    // 检查是否按下了Backspace键
    if (e.key === 'Backspace' || e.keyCode === 8) {
      // 如果焦点在一个可编辑的元素上（例如input或textarea），则允许Backspace键的操作
      const activeElement = document.activeElement;
      const isEditable = activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable;

      if (isEditable) {
        return; // 允许Backspace操作
      }else{
        // 阻止默认行为
        e.preventDefault();
        alert('不能后退')
      }
    }
  });
});

